package cn.zucc.edu.madq.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.zucc.edu.madq.dao.MessageMapper;
import cn.zucc.edu.madq.pojo.Message;
import cn.zucc.edu.madq.service.MessageService;

@Service("messageService")
public class MessageServiceImpl implements MessageService {

	@Autowired
	private MessageMapper messageMapper;

	@Override
	public int getMessageNum(int userId) {
		return messageMapper.getMessageNum(userId);
	}

	@Override
	public List<Message> getAllMessage(Integer userId) {
		return messageMapper.getAllMessage(userId);
	}

	@Override
	public int delMessage(int messageId) {
		return messageMapper.deleteByPrimaryKey(messageId);
	}

	@Override
	public Message getMessageById(int messageId) {
		return messageMapper.selectByPrimaryKey(messageId);
	}

	@Override
	public int readMessage(Message message) {
		return messageMapper.updateByPrimaryKeySelective(message);
	}

	@Override
	public int addMessage(Message m) {
		return messageMapper.insert(m);
	}

}
